package com.smart.system.domain;

import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import com.smart.common.annotation.Excel;
import lombok.Data;
import lombok.Builder;
import com.smart.common.core.domain.BaseEntity;

import lombok.*;

/**
 * 车辆移动轨迹对象 car_trajectory
 *
 * @author smart
 * @date 2024-11-01
 */
@Data
@Builder
@TableName("car_trajectory")
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
public class CarTrajectory extends BaseEntity{
private static final long serialVersionUID = 1L;

    /** $column.columnComment */
    @Schema(description ="${comment}")
    @TableField(value = "id",exist = true)
    @TableId(type = IdType.AUTO)
    private Integer id;

    /** 部门id */
    @Excel(name = "部门id")
    @Schema(description ="部门id")
    @TableField(value = "dept_id",exist = true)
    private Integer deptId;

    /** 版本 */
    @Excel(name = "版本")
    @Schema(description ="版本")
    @TableField(value = "revision",exist = true)
    private Integer revision;

    /** 是否删除 */
    @Schema(description ="是否删除")
    @TableField(value = "del_flag",exist = true)
    private String delFlag;

    /** 状态 */
    @Excel(name = "状态")
    @Schema(description ="状态")
    @TableField(value = "status",exist = true)
    private String status;

    /** 用户id */
    @Excel(name = "车辆id")
    @Schema(description ="用户id")
    @TableField(value = "car_id",exist = true)
    private Integer carId;

    /** json对象 */
    @Excel(name = "json对象")
    @Schema(description ="json对象")
    @TableField(value = "json_string",exist = true)
    private String jsonString;

    /** 油量 **/
    @Excel(name = "油量")
    @Schema(description ="油量")
    @TableField(value = "oil_level",exist = true)
    private Double oilLevel;

    /**时速**/
    @Excel(name = "时速")
    @Schema(description ="时速")
    @TableField(value = "speed",exist = true)
    private Double speed;

    @Schema(description ="排序")
    @TableField(exist = false)
    private Integer sort;

    @Schema(description = "坐标经纬度")
    @TableField(exist = false)
    private AreaLocation areaLocation;
    public void setJsonString(String jsonString) {
        this.jsonString = jsonString;
        this.areaLocation = JSON.parseObject(jsonString, AreaLocation.class);
    }

    public void setAreaLocation(AreaLocation areaLocation) {
        this.areaLocation = areaLocation;
        this.jsonString = JSON.toJSONString(areaLocation);
    }
    public AreaLocation getAreaLocation(){
        return JSON.parseObject(jsonString, AreaLocation.class);
    }
}